package com.datastructure.test.duplicatenumberinarray;

import java.util.Arrays;

public class DuplicateNumberInArray {

    public static void main(String[] args) {

    }

    public int duplicate (int[] numbers) {
        // write code here
        Arrays.sort(numbers);
        for (int i = 0; i < numbers.length-1; i++) {
            if(numbers[i]==numbers[i+1]){
                return numbers[i];
            }
        }
        return -1;
    }
}
